﻿/********************************************************************
FileName    :   Bll_OS.cs
CreateTime  :   2020-11-09 08:14:31
BaseClass   :   Bll_OS
FileType    :   .cs
Author      :  minjie
Description :   Bll_OS层（简单三层）
*********************************************************************/

using System;
using System.Text;
using System.Collections.Generic;

using System.Data;
using OS.DAL;
namespace OS.BLL
{
	/// <summary>
	/// Bll_sys_DICTIONARY的摘要说明。
	/// </summary>
    public partial class   Bll_yw_pfdH
  	{ 
     		      
  		private readonly Dal_yw_pfdH dal=new  Dal_yw_pfdH(); 
  		public  Bll_yw_pfdH() 
  		{} 
  		 
  		#region  Method 
     		      
  		public bool Exists(int DjLsh) 
  		{ 
  			return dal.Exists(DjLsh); 
  		}
        public bool Exists(string xsdh, ref int djlsh)
        {
            return dal.Exists(xsdh,ref djlsh);
        }
        public int GetNewLsh()
        {
            int newLsh = 0;
            string sql = " select djlsh  from dbo.STDjLsh  where djname='YW_PFD'";
            string sql2 = "update STDjLsh set djlsh=djlsh+1 where djname='YW_PFD'";
            string obj = dal.GetSingle(sql);
            int ss = dal.ExecuteSql(sql2);
            if (obj != null && obj.ToString() != "")
            {
                newLsh = int.Parse(obj.ToString());
            }
            return newLsh;
        }
        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public bool  Add(yw_pfdH_Entity model) 
  		{ 
  			return dal.Add(model); 
  		} 
   
  		/// <summary> 
  		/// 增加一条数据 
  		/// </summary> 
  		public  string  AddStr(yw_pfdH_Entity model) 
  		{ 
  			return dal.AddStr(model); 
  		} 
   
  		/// <summary> 
  		/// 更新一条数据 
  		/// </summary> 
  		public bool Update(yw_pfdH_Entity model) 
  		{ 
  			return dal.Update(model); 
  		} 
   
  		/// <summary> 
  		/// 更新一条数据(字符串) 
  		/// </summary> 
  		public string UpdateStr(yw_pfdH_Entity model) 
  		{ 
  			return dal.UpdateStr(model); 
  		} 
   
  		/// <summary> 
  		/// 删除一条数据 
  		/// </summary> 
  		public bool Delete(int DjLsh) 
  		{ 
  			 
  			return dal.Delete(DjLsh); 
  		} 
  		/// <summary> 
  		/// 批量删除一批数据 
  		/// </summary> 
  		public bool DeleteList(string lists ) 
  		{ 
  			return dal.DeleteList(lists ); 
  		} 
  		/// <summary> 
  		/// 得到一个对象实体 
  		/// </summary> 
  		public yw_pfdH_Entity  GetModel(int DjLsh) 
  		{ 
  			 
  			return dal.GetModel(DjLsh); 
  		} 
   
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public DataSet GetList(string strWhere) 
  		{ 
  			return dal.GetList(strWhere); 
  		} 
  		/// <summary> 
  		/// 获得数据count 
  		/// </summary> 
  		public int GetCount(string strWhere) 
  		{ 
  			return dal.GetRecordCount(strWhere); 
  		} 
  	 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<yw_pfdH_Entity> GetModelList(string strWhere) 
  		{ 
  			DataSet ds = dal.GetList(strWhere); 
  			return DataTableToList(ds.Tables[0]); 
  		} 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<yw_pfdH_Entity> GetModelList(string strWhere, string orderby, int startIndex, int endIndex) 
  		{ 
  			DataSet ds = dal.GetListByPage(strWhere, orderby, startIndex, endIndex); 
  			return DataTableToList(ds.Tables[0]); 
  		} 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<yw_pfdH_Entity> DataTableToList(DataTable dt) 
  		{ 
  			List<yw_pfdH_Entity> modelList = new List<yw_pfdH_Entity>(); 
  		  if (dt!=null ) 
  		  { 
  			int rowsCount = dt.Rows.Count; 
  			if (rowsCount > 0) 
  			{ 
  				yw_pfdH_Entity   model; 
  				for (int n = 0; n < rowsCount; n++) 
  				{ 
  				model = new yw_pfdH_Entity();					 
  			    
			      if (dt.Rows[n]["DjLsh"] != null && dt.Rows[n]["DjLsh"].ToString() != "")
                model.DjLsh = int.Parse(dt.Rows[n]["DjLsh"].ToString());
			  
	        
			      if (dt.Rows[n]["DjBtZdh"] != null && dt.Rows[n]["DjBtZdh"].ToString() != "")
                model.DjBtZdh = int.Parse(dt.Rows[n]["DjBtZdh"].ToString());
			  
	        
			      if (dt.Rows[n]["DjFtZdh"] != null && dt.Rows[n]["DjFtZdh"].ToString() != "")
                model.DjFtZdh = int.Parse(dt.Rows[n]["DjFtZdh"].ToString());
			  
	        
			      if (dt.Rows[n]["DjStZdh"] != null && dt.Rows[n]["DjStZdh"].ToString() != "")
                model.DjStZdh = int.Parse(dt.Rows[n]["DjStZdh"].ToString());
			  
	        model.DjState = dt.Rows[n]["DjState"].ToString();
	        
			      if (dt.Rows[n]["DjCount"] != null && dt.Rows[n]["DjCount"].ToString() != "")
                model.DjCount = int.Parse(dt.Rows[n]["DjCount"].ToString());
			  
	        if (dt.Rows[n]["xsrq"] != null && dt.Rows[n]["xsrq"].ToString() != "")
			  model.xsrq = DateTime.Parse(dt.Rows[n]["xsrq"].ToString());
			  
	        if (dt.Rows[n]["xssj"] != null && dt.Rows[n]["xssj"].ToString() != "")
			  model.xssj = DateTime.Parse(dt.Rows[n]["xssj"].ToString());
			  
	        model.djzt = dt.Rows[n]["djzt"].ToString();
	        model.xsdh = dt.Rows[n]["xsdh"].ToString();
	        model.bmbh = dt.Rows[n]["bmbh"].ToString();
	        model.bmmc = dt.Rows[n]["bmmc"].ToString();
	        model.ckbh = dt.Rows[n]["ckbh"].ToString();
	        model.ckmc = dt.Rows[n]["ckmc"].ToString();
	        model.khbh = dt.Rows[n]["khbh"].ToString();
	        model.khmc = dt.Rows[n]["khmc"].ToString();
	        model.tel = dt.Rows[n]["tel"].ToString();
	        model.khqy = dt.Rows[n]["khqy"].ToString();
	        model.yyybh = dt.Rows[n]["yyybh"].ToString();
	        model.yyyh = dt.Rows[n]["yyyh"].ToString();
	        model.fplx = dt.Rows[n]["fplx"].ToString();
	        model.thydh = dt.Rows[n]["thydh"].ToString();
	        model.sjdr = dt.Rows[n]["sjdr"].ToString();
	        if (dt.Rows[n]["slhj"] != null && dt.Rows[n]["slhj"].ToString() != "")
			  model.slhj = decimal.Parse(dt.Rows[n]["slhj"].ToString());
			
	        if (dt.Rows[n]["jehj"] != null && dt.Rows[n]["jehj"].ToString() != "")
			  model.jehj = decimal.Parse(dt.Rows[n]["jehj"].ToString());
			
	        if (dt.Rows[n]["cbjehj"] != null && dt.Rows[n]["cbjehj"].ToString() != "")
			  model.cbjehj = decimal.Parse(dt.Rows[n]["cbjehj"].ToString());
			
	        if (dt.Rows[n]["zhjehj"] != null && dt.Rows[n]["zhjehj"].ToString() != "")
			  model.zhjehj = decimal.Parse(dt.Rows[n]["zhjehj"].ToString());
			
	        if (dt.Rows[n]["jszje"] != null && dt.Rows[n]["jszje"].ToString() != "")
			  model.jszje = decimal.Parse(dt.Rows[n]["jszje"].ToString());
			
	        if (dt.Rows[n]["ssjehj"] != null && dt.Rows[n]["ssjehj"].ToString() != "")
			  model.ssjehj = decimal.Parse(dt.Rows[n]["ssjehj"].ToString());
			
	        model.bz = dt.Rows[n]["bz"].ToString();
	        if (dt.Rows[n]["zdzk"] != null && dt.Rows[n]["zdzk"].ToString() != "")
			  model.zdzk = decimal.Parse(dt.Rows[n]["zdzk"].ToString());
			
	        if (dt.Rows[n]["zsz"] != null && dt.Rows[n]["zsz"].ToString() != "")
			  model.zsz = decimal.Parse(dt.Rows[n]["zsz"].ToString());
			
	        if (dt.Rows[n]["zr"] != null && dt.Rows[n]["zr"].ToString() != "")
			  model.zr = decimal.Parse(dt.Rows[n]["zr"].ToString());
			
	        if (dt.Rows[n]["xj"] != null && dt.Rows[n]["xj"].ToString() != "")
			  model.xj = decimal.Parse(dt.Rows[n]["xj"].ToString());
			
	        if (dt.Rows[n]["qk"] != null && dt.Rows[n]["qk"].ToString() != "")
			  model.qk = decimal.Parse(dt.Rows[n]["qk"].ToString());
			
	        if (dt.Rows[n]["zl"] != null && dt.Rows[n]["zl"].ToString() != "")
			  model.zl = decimal.Parse(dt.Rows[n]["zl"].ToString());
			
	        if (dt.Rows[n]["ysk"] != null && dt.Rows[n]["ysk"].ToString() != "")
			  model.ysk = decimal.Parse(dt.Rows[n]["ysk"].ToString());
			
	        if (dt.Rows[n]["wsk"] != null && dt.Rows[n]["wsk"].ToString() != "")
			  model.wsk = decimal.Parse(dt.Rows[n]["wsk"].ToString());
			
	        if (dt.Rows[n]["yskye"] != null && dt.Rows[n]["yskye"].ToString() != "")
			  model.yskye = decimal.Parse(dt.Rows[n]["yskye"].ToString());
			
	        if (dt.Rows[n]["djye"] != null && dt.Rows[n]["djye"].ToString() != "")
			  model.djye = decimal.Parse(dt.Rows[n]["djye"].ToString());
			
	        if (dt.Rows[n]["djzf"] != null && dt.Rows[n]["djzf"].ToString() != "")
			  model.djzf = decimal.Parse(dt.Rows[n]["djzf"].ToString());
			
	        model.zdr = dt.Rows[n]["zdr"].ToString();
	        if (dt.Rows[n]["zdsj"] != null && dt.Rows[n]["zdsj"].ToString() != "")
			  model.zdsj = DateTime.Parse(dt.Rows[n]["zdsj"].ToString());
			  
	        model.shr = dt.Rows[n]["shr"].ToString();
	        if (dt.Rows[n]["shsj"] != null && dt.Rows[n]["shsj"].ToString() != "")
			  model.shsj = DateTime.Parse(dt.Rows[n]["shsj"].ToString());
			  
	        if (dt.Rows[n]["hkrq"] != null && dt.Rows[n]["hkrq"].ToString() != "")
			  model.hkrq = DateTime.Parse(dt.Rows[n]["hkrq"].ToString());
			  
	        model.hkbj = dt.Rows[n]["hkbj"].ToString();
	        model.sjhm = dt.Rows[n]["sjhm"].ToString();
	        
  				 modelList.Add(model); 
  				}
  			}
  		}
  			return modelList; 
  		} 
   
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public DataSet GetAllList() 
  		{ 
  			return GetList(""); 
  		} 
   
  		/// <summary> 
  		/// 批量处理 
  		/// </summary> 
  		public int ExecuteSqlTran(List<string> ls,ref string error ) 
  		{ 
  			return dal.ExecuteSqlTran(ls,ref   error); 
  		} 
   
  		/// <summary> 
  		/// 直接执行sql语句 
  		/// </summary> 
  		public int ExecuteSql(string sql) 
  		{ 
  			return dal.ExecuteSql(sql); 
  		} 
   
  		/// <summary> 
  		/// 直接执行sql语句 
  		/// </summary> 
  		public string GetSingle(string sql) 
  		{ 
  			return dal.GetSingle(sql); 
  		} 
   
  		/// <summary> 
  		/// 直接执行sql语句 
  		/// </summary> 
  		public DataTable ExecuteDt(string sql) 
  		{ 
  			return dal.ExecuteDt(sql); 
  		} 
   
  		/// <summary> 
  		/// 获取记录总数 
  		/// </summary> 
  		public int GetRecordCount(string strWhere) 
  		{ 
  			return  dal.GetRecordCount(strWhere); 
  		} 
  #endregion 
      
  	} 
  
}
